run

您所在的位置:网站首页 run App in deamon mode run

run

2024-07-16 22:51| 来源: 网络整理| 查看: 265

run

Run tasks specified in turbo.json.

Terminalturbo run [tasks] [options] [-- [args passed to tasks]] [tasks]: Turborepo can run one or many tasks at the same time. To run a task through turbo, it must be specified in turbo.json. [options]: Options are used to control the behavior of the turbo run command. Available flag options are described below. [-- [args passed to tasks]]: You may also pass arguments to the underlying scripts. Note that all arguments will be passed to all tasks.

Good to know:

turbo run is aliased to turbo. turbo run build lint check-types is the same as turbo build lint check-types. We recommend using turbo run in CI pipelines and turbo with global turbo locally for ease of use.

Options --cache-dir

Default: .turbo/cache

Specify the filesystem cache directory.

Terminalturbo run build --cache-dir="./my-cache"

Ensure the directory is in your .gitignore when changing it.

--concurrency

Default: 10

Set/limit the maximum concurrency for task execution. Must be an integer greater than or equal to 1 or a percentage value like 50%.

Use 1 to force serial execution (one task at a time). Use 100% to use all available logical processors. This option is ignored if the --parallel flag is also passed. Terminalturbo run build --concurrency=50% turbo run test --concurrency=5 --continue

Default: false

Continue with task execution in the presence of an error (e.g. non-zero exit code from a task).

When --continue is true, turbo will exit with the highest exit code value encountered during execution.

Good to know:

Specifying the --parallel flag will automatically set --continue to true unless explicitly set to false.

Terminalturbo run build --continue --cwd

Default: Directory of root turbo.json

Set the working directory of the command.

Terminalturbo run build --cwd=./somewhere/else/in/your/repo --dry / --dry-run

Instead of executing tasks, display details about the packages and tasks that would be run.

Specify --dry=json to get the output in JSON format.

Task details include useful information like (list is non-exhaustive):

FieldDescriptiontaskIdID for the task, in the format of package-name#task-nametaskThe name of the task to be executedpackageThe package in which to run the taskhashThe hash of the task (used for caching)hashOfExternalDependenciesThe global hashcommandThe command used to run the taskinputsList of file inputs considered for hashingoutputsList of file outputs that were cacheddependenciesTasks that must run before this taskdependentsTasks that must run after this taskenvironmentVariablesLists of environment variables specified in env and passThroughEnv --env-mode

type: string

Controls the available environment variables in the task's runtime.

Good to know:

PATH, SHELL, and SYSTEMROOT are always available to the task.

optiondescriptionstrict (Default)Only allow explicitly listed environment variables to be availablelooseAllow all environment variables to be available Terminalturbo run build --env-mode=loose strict

Only environment variables specified in the following keys are available to the task:

env passThroughEnv globalEnv globalPassThroughEnv

If Strict Mode is specified or inferred, all tasks are run in strict mode, regardless of their configuration.

loose

All environment variables on the machine are made available to the task's runtime.

This can be dangerous when environment variables are not accounted for in caching with the keys listed in strict above. You're much more likely to restore a version of your package with wrong environment variables from cache in loose mode.

--filter

Specify targets to execute from your repository's graph. Multiple filters can be combined to select distinct sets of targets.

Filters can be combined to create combinations of packages, directories, and git commits.

Target typeDescriptionExamplePackageSelect a package by its name in package.json.turbo run build --filter=uiDirectorySpecify directories to capture a list of packages to run tasks. When used with other filters, must be wrapped in {}.turbo run build --filter=./apps/*Git commitsUsing Git specifiers, specify packages with source control changes. Must be wrapped in [].turbo run build --filter=[HEAD^1]

Good to know:

-F is an alias for --filter. Microsyntaxes for filtering !: Negate targets from the selection. ... using packages: Select all packages in the Package Graph relative to the target. Using ... before the package name will select dependents of the target while using ... after the package name will select dependencies of the target. ... using Git commits: Select a range using []...[]. ^: Omit the target from the selection when using ....

For in-depth discussion and practical use cases of filtering, visit the Running Tasks page.

Advanced filtering examples

You can combine multiple filters to further refine your targets. Multiple filters are combined as a union, meaning that the Task Graph will include tasks that match any of the filters.

Terminal# Any packages in `apps` subdirectories that have changed since the last commit turbo run build --filter=.apps/* --filter=[HEAD^1] # Any packages in `apps` subdirectories except ./apps/admin turbo run build --filter=./apps/* --filter=!./apps/admin # Run the build task for the docs and web packages turbo run build --filter=docs --filter=web # Build everything that depends on changes in branch 'my-feature' turbo run build --filter=...[origin/my-feature] # Build everything that depends on changes between two Git SHAs turbo run build --filter=[a1b2c3d...e4f5g6h] # Build '@acme/ui' if: # - It or any of its dependencies have changed since the previous commit turbo run build --filter=@acme/ui...[HEAD^1] # Test each package that is: # - In the '@acme' scope # - Or, in the 'packages' directory # - Or, changed since the previous commit turbo run test --filter=@acme/*{./packages/*}[HEAD^1] --force

Ignore existing cached artifacts and re-execute all tasks.

Good to know:

--force will overwrite existing task caches.

Terminalturbo run build --force

The same behavior can also be set via the TURBO_FORCE environment variable.

--framework-inference

Default: true

Specify whether or not to do Framework Inference for tasks.

When false, automatic environment variable inclusion is disabled.

Terminalturbo run build --framework-inference=false --global-deps

Specify glob of global filesystem dependencies to be hashed. Useful for .env and files in the root directory that impact multiple packages.

Terminalturbo run build --global-deps=".env" turbo run build --global-deps=".env.*" --global-deps=".eslintrc" --global-deps="jest.config.js"

We recommend specifying file globs that you'd like to include your hashes in the globalDependencies key in turbo.json to make sure they are always accounted for.

--graph

Default: jpg

This command will generate an svg, png, jpg, pdf, json, html, or other supported output formats of the current task graph.

If Graphviz is not installed, or no filename is provided, this command prints the dot graph to stdout.

Terminalturbo run build --graph turbo run build test lint --graph=my-graph.svg

Known Bug: All possible task nodes will be added to the graph at the moment, even if that script does not actually exist in a given package. This has no impact on execution, but the graph may overstate the number of packages and tasks involved.

--log-order

Default: auto

Set the ordering for log output.

By default, turbo will use grouped logs in CI environments and stream logs everywhere else. This flag is not applicable when using the terminal UI.

Terminalturbo run build --log-order=stream OptionDescriptionstreamShow output as soon as it is availablegroupedGroup output by taskautoTurbo decides based on its own heuristics --log-prefix

Default: auto

Control the :: prefix for log lines produced when running tasks.

Terminalturbo run dev --log-prefix=none OptionDescriptionprefixForce prepending the prefix to logsnoneNo prefixesautoturbo decides based on its own heuristics --no-cache

Default false

Do not cache results of the task.

Terminalturbo run dev --no-cache --no-daemon

Default: false

turbo can run a background process to pre-calculate values used for determining work that needs to be done. This standalone process (daemon) is an optimization, and not required for proper functioning of turbo.

Passing --no-daemon instructs turbo to avoid using or creating the standalone process.

--output-logs

Default: full

Set type of output logging, overriding outputLogs if it's defined in turbo.json.

Terminalturbo run build --output-logs=errors-only OptionDescriptionfullDisplays all logshash-onlyOnly show the hashes of the tasksnew-onlyOnly show logs from cache misseserrors-onlyOnly show logs from task failuresnoneHides all task logs --only

Default: false

Restricts execution to include specified tasks only.

Example

Given this turbo.json:

./turbo.json{ "$schema": "https://turbo.build/schema.json", "tasks": { "build": { "dependsOn": ["^build"] }, "test": { "dependsOn": ["^build"] } } } Terminalturbo run test --only

The command will only execute the test tasks in each package. It will not run build.

Additionally, --only will only run tasks in specified packages, excluding dependencies. For example, turbo run build --filter=web --only, will only run the build script in the web package.

--parallel

Default: false

Run commands in parallel across packages, ignoring the task dependency graph.

Terminalturbo run lint --parallel turbo run dev --parallel

The --parallel flag is typically used for long-running "dev" or "watch" tasks that don't exit. Starting in [email protected], we recommend configuring these tasks using persistent instead.

--preflight

Only applicable when Remote Caching is configured. Enables sending a preflight request before every cache artifact and analytics request. The follow-up upload and download will follow redirects.

Terminalturbo run build --preflight

The same behavior can also be set via the TURBO_PREFLIGHT=true system variable.

--profile

Generates a trace of the run in Chrome Tracing format that you can use to analyze performance.

You must provide a verbosity flag (-v, -vv, or -vvv) with --profile to produce a trace.

Terminalturbo run build --profile=profile.json -vvv

Profiles can be viewed in a tool like Perfetto.

--remote-cache-timeout

Default: 30

Set the timeout for Remote Cache operations in seconds.

Terminalturbo run build --remote-cache-timeout=60 --remote-only

Default: false

Ignore the local filesystem cache for all tasks, using Remote Cache for reading and caching task outputs.

Terminalturbo run build --remote-only --summarize

Generates a JSON file in .turbo/runs containing metadata about the run, including:

Affected packages Executed tasks (including their timings and hashes) All the files included in the cached artifact Terminalturbo run build --summarize

This flag can be helpful for debugging to determine things like:

How turbo interpreted your glob syntax for inputs and outputs What inputs changed between two task runs to produce a cache miss How task timings changed over time --token

A bearer token for Remote Caching. Useful for running in non-interactive shells in combination with the --team flag.

Terminalturbo run build --team=my-team --token=xxxxxxxxxxxxxxxxx

This value can also be set using the TURBO_TOKEN system variable. If both are present, the flag value will override the system variable.

Good to know:

If you are using Vercel Remote Cache and building your project on Vercel, you do not need to use this flag. This value will be automatically set for you.

--team

The slug of the Remote Cache team. Useful for running in non-interactive shells in combination with the --token flag.

Terminalturbo run build --team=my-team turbo run build --team=my-team --token=xxxxxxxxxxxxxxxxx

This value can also be set using the TURBO_TEAM system variable. If both are present, the flag value will override the system variable.

--verbosity

To specify log level, use --verbosity= or -v, -vv, -vvv.

LevelFlag valueShorthandInfo--verbosity=1-vDebug--verbosity=2-vvTrace--verbosity=3-vvv Terminalturbo run build --verbosity=2 turbo run build -vvv

Was this helpful?



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3